<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function sort(arr){
            if (!Array.isArray(arr)) return arr; 
            for(let i = 0;i <arr.length; i++){
                for(let j = 0; j<arr.length-i;j++){
                    if(arr[j] > arr[j+1]){
                        swap(arr,j,j+1);
                    }
                }
            }
            return arr;
        }
        
        function swap(arr, i, j) {
        if (!Array.isArray(arr)) return; 
        if (i < 0 || j < 0) return;     
        if (i >= arr.length || j >= arr.length) return;
        
        [arr[i], arr[j]] = [arr[j], arr[i]];
    }

    console.log(sort( [2, 6, 1, 77, 52, 0, 25, 7, 43, 71, 92, 88]));
    </script>
</body>
</html>
